#!/usr/bin/python
# -*- coding: utf-8 -*-

""" 例外處理 """


def test_exception(c):
	print "test_exception: c = %r" % (c,)
	try:
		l = len(c)
		aux = 10 / l
		print "test_exception: 10/len(c) = %r" % (aux,)
	except ZeroDivisionError:
		print "test_exception: ZeroDivisionError (l=%r)" % (l,)
	except TypeError as e:
		print "test_exception: TypeError:", e
	else:
		print "test_exception: in -else- code block"
	finally:
		print "test_exception: in -finally- code block"
# ### test_exception(c)


test_exception([1, 2, 3,])
test_exception([])
test_exception(100)



try:
	print "going to caculate \"a = 1 / 0\"."
	a = 1 / 0
	print "caculated \"a = 1 / 0\"."
except Exception as e:
	pass
print "code finished."



# vim: ts=4 sw=4 foldmethod=marker ai nowrap
